home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / t3_1 / risc_src.lha / risc_sources / comp / back_end / spbookkeep.t < prev    next >
Encoding:
Text File  |  1989-12-05  |  4.5 KB  |  165 lines

  1. (herald spbookkeep); (env t (orbit_top defs)))
  2.  
  3. ;;; Copyright (c) 1985 Yale University
  4. ;;;     Authors: N Adams, R Kelsey, D Kranz, J Philbin, J Rees.
  5. ;;; This material was developed by the T Project at the Yale University Computer 
  6. ;;; Science Department.  Permission to copy this software, to redistribute it, 
  7. ;;; and to use it for any purpose is granted, subject to the following restric-
  8. ;;; tions and understandings.
  9. ;;; 1. Any copy made of this software must include this copyright notice in full.
  10. ;;; 2. Users of this software agree to make their best efforts (a) to return
  11. ;;;    to the T Project at Yale any improvements or extensions that they make,
  12. ;;;    so that these may be included in future releases; and (b) to inform
  13. ;;;    the T Project of noteworthy uses of this software.
  14. ;;; 3. All materials developed as a consequence of the use of this software
  15. ;;;    shall duly acknowledge such use, in accordance with the usual standards
  16. ;;;    of acknowledging credit in academic research.
  17. ;;; 4. Yale has made no warrantee or representation that the operation of
  18. ;;;    this software will be error-free, and Yale is under no obligation to
  19. ;;;    provide any services, by way of maintenance, update, or otherwise.
  20. ;;; 5. In conjunction with products arising from the use of this material,
  21. ;;;    there shall be no use of the name of the Yale University nor of any
  22. ;;;    adaptation thereof in any advertising, promotional, or sales literature
  23. ;;;    without prior written consent from Yale in each case.
  24. ;;;
  25.  
  26.  
  27. (define *stack-registers* 0)
  28. (define *real-registers*
  29.   (+ *argument-registers* *stack-registers* 3)) ;an,p,an+1
  30. (define *first-stack-register* (+ *argument-registers* 3))
  31. (define AN (fx+ *argument-registers* 1)) ;i4
  32. (define AN-1 (fx- AN 1))
  33. (define AN+1 (fx+ AN 1))        ;g3
  34. (define *virtual-registers* 128)
  35.  
  36. (define P 0)                ;l0
  37. (define A1 1)                ;l1
  38. (define A2 2)
  39. (define A3 3)
  40. (define A4 4)
  41. (define A5 5)
  42. (define A6 6)
  43. (define A7 7)                ;l7
  44. (define A8 8)                ;i0
  45. (define A9 9)                ;i1
  46. (define A10 10)
  47. (define A11 11)                ;i3
  48.  
  49.  
  50. (define zero -1)            ;g0
  51. (define extra-args -2)            ;o1
  52. (define EXTRA -3)            ;o2
  53. (define scratch -4)            ;o5
  54. (define nil-reg -5)            ;i5
  55. (define parassign-extra -6)        ;o3
  56. (define VECTOR -7)            ;o4
  57. (define t-reg -8)            ;g2
  58. (define sp -9)                ;g1
  59. (define link-reg -10)            ;o7
  60. (define ass-reg -11)            ;o0
  61. (define crit-reg -12)            ;i7
  62. (define ssp -13)            ;o6
  63.  
  64. (define nargs scratch)
  65.  
  66.  
  67. #|
  68. (define *stack-registers* 13)
  69. (define *real-registers*
  70.   (+ *argument-registers* *stack-registers* 3)) ;an,p,an+1
  71. (define *first-stack-register* (+ *argument-registers* 3))
  72. (define AN (fx+ *argument-registers* 1)) ;o0
  73. (define AN-1 (fx- AN 1))
  74. (define AN+1 (fx+ AN 1))        ;o1
  75. (define *virtual-registers* 64)
  76.  
  77. (define S0 (+ AN 2))
  78. (define S1 (+ AN 3))
  79. (define S2 (+ AN 4))
  80. (define S3 (+ AN 5))
  81. (define S4 (+ AN 6))
  82. (define S5 (+ AN 7))
  83. (define S6 (+ AN 8))
  84.  
  85. (define P 0)                ;g1
  86. (define A1 1)                ;g2
  87. (define A2 2)                ;g3
  88. (define A3 3)                ;g4
  89. (define A4 4)                ;g5
  90. (define A5 5)                ;g6
  91.  
  92. (define zero -1)            ;g0
  93. (define extra-args -2)            ;o2
  94. (define EXTRA -3)            ;o3
  95. (define scratch -4)            ;o4
  96. (define nil-reg -5)            ;g7
  97. (define parassign-extra -6)        ;i0
  98. (define VECTOR -7)            ;o5
  99. ;(define t-reg -8)            
  100. (define sp -8)                ;o6
  101. (define link-reg -9)            ;o7
  102. ;(define ass-reg -11)            
  103. ;(define crit-reg -12)
  104. ;(define ssp -13)
  105. (define nargs scratch)
  106. |#
  107. (define ($ x) (error "used $"))
  108.  
  109. (define-integrable (reg-offset x y) (cons x y))
  110. #|
  111. (define (machine-true-value) (machine-num header/true))
  112. |#
  113.  
  114. (define (machine-true-value) t-reg)
  115.  
  116. (define (representable-fixnum? x op)                 
  117.   (and (fixnum? x)
  118.        (fx>= x #x-400)
  119.        (fx< x #x400)))            ;13 bits signed -2
  120.  
  121. (define *max-displ* #xfff)
  122.  
  123. (define *max-extend-displ* (- #xfff 2))
  124.  
  125. (define (addressable? value)
  126.   (or (target-fixnum? value)
  127.       (char? value)
  128.       (eq? value '#t)
  129.       (eq? value '#F)))
  130.  
  131. (define-constant target-fixnum? fixnum?)
  132.  
  133. (define-integrable (machine-num x)
  134.   (if (fx= x 0) zero (cons 'lit x)))
  135. (define-integrable (unsigned-num x) (cons 'unsigned x))
  136.  
  137. (define (reference-addressable node x)
  138.   (xcond ((representable-fixnum? x 'move)
  139.       (machine-num (* x 4)))
  140.          ((or (fixnum? x) (char? x))
  141.       (let ((reg (get-register node)))
  142.         (generate-move-addressable x reg)
  143.         (mark x reg)
  144.         reg))
  145.      ((not x) nil-reg)
  146.      ((eq? x '#t) (machine-true-value))))
  147.  
  148.  
  149. (define-integrable (register? x)
  150.   (and (fixnum? x) (fx< x *real-registers*)))
  151.  
  152.  
  153. (define (allowed-mode? x)
  154.   (or (register? x)
  155.       (and (pair? x)
  156.        (eq? (car x) 'lit))))
  157.  
  158.  
  159. (define (arith->addressable node var op)
  160.   (cond ((representable-fixnum? var op)
  161.      (machine-num (fx* var 4)))
  162.     (else
  163.      (->register node var))))
  164.  
  165.